package com.macro.mall.tiny.controller;

        import com.macro.mall.tiny.common.api.CommonPage;
        import com.macro.mall.tiny.common.api.CommonResult;
        import com.macro.mall.tiny.mbg.model.PmsBrand;
        import com.macro.mall.tiny.service.PmsBrandService;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.stereotype.Controller;
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.bind.annotation.RequestMethod;
        import org.springframework.web.bind.annotation.RequestParam;
        import org.springframework.web.bind.annotation.ResponseBody;

        import java.util.List;

/**
 * 品牌管理Controller
 */
@Controller
@RequestMapping("/brand")
public class PmsBrandController {
    @Autowired
    private PmsBrandService pmsBrandService;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ResponseBody                               //@RequestParam接受前台的请求参数            //defaultValue  默认值
    public CommonResult<CommonPage<PmsBrand>> listBrand(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                        @RequestParam(value = "pageSize",defaultValue = "3") Integer pageSize){
        List<PmsBrand> list = pmsBrandService.listBrand(pageNum,pageSize);
        return CommonResult.success(CommonPage.restPage(list),null);
    }

    @RequestMapping(value = "/creat",method = RequestMethod.GET)
    @ResponseBody
    public int createBrand(PmsBrand pmsBrand) {
        return pmsBrandService.createBrand(pmsBrand);
    }
    @RequestMapping(value = "/update",method = RequestMethod.GET)
    @ResponseBody
    public int updateBrand(Long id, PmsBrand pmsBrand) {
        return pmsBrandService.updateBrand(id, pmsBrand);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.GET)
    @ResponseBody
    public int deleteBrand(Long id) {
        return pmsBrandService.deleteBrand(id);
    }

}
